#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int pd(int a)
{
	int one,two,three=10,four=a,sum=0;
	for (int j = 1; j < 5;four=a, j++)
	{

		one = four % three;
		
		two = four/three;
		sum += one * two;
		three *= 10;
	}
	if (sum == a)
		return 1;


	return 0;
}


int main()
{
	int a;
	for (int i = 10000; i <= 99999; i++)
	{
		
		if (pd(i))
			if (i == 10000)
				printf("%d", i);
			else
				printf(" %d", i);
	}


	return 0;
}